<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'reg.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		#info{
			border:1px solid #000;
			background-color: #ccc;
			font-size: 12px;
		}
	</style>
	<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript">
	$( function(){
		  //文本框失去焦点
		  $("#uname").blur(function(e) {
                $.get("userServlet",{uname:$("#uname").val()}, 
						function (data,status){
							//alert(data+"----"+status);
							//用户名存在
							if( "true"==data ){
								$("#info").html("用户名已存在");
								$("#btn1").attr("disabled","disabled");
							}else{
								$("#info").html("用户名可以注册");
								$("#btn1").removeAttr("disabled");
							}
						}
				   );
          });
		
		});
	
	</script>


  </head>
  
  <body>
    <form action="" name="form1">
    用户账号：<input type="text" name="uname" id="uname">
    <span id="info"></span><br/>
  用户密码:  <input type="password" name="upwd" id="upwd"><br/>
  <input type="submit" value="注册" id="btn1"> 
    </form>
    
    
    
  </body>
</html>
